<script setup>
import {useRoute} from "vue-router";
import {watch} from "vue";

let route = useRoute()

console.log(route);
console.log(route.params);

watch(
    () => route.params.id,
    (newId, oldId) => {
      // 对路由变化做出响应...
      console.log("用户由 news " + oldId + " 跳转到 " + newId);
    },
    {
      immediate: true,
    }
)
</script>

<template>
  <h1>News 页面</h1>
  <div>当前的文章编号是：{{ $route.params.id }}</div>
  <div>当前的 get 请求参数是：{{ $route.query }}</div>


  <div>当前的文章编号是：{{ route.params.id }}</div>
  <div>当前的 get 请求参数是：{{ route.query }}</div>
</template>

<style scoped>

</style>